﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Demos.util;
using mendian;
using DXApplicationTangche.DTO;
using DXApplicationTangche.UC.面料库存.库存记录.service;

namespace DXApplicationTangche.UC.面料库存
{
    public partial class Form面料日记账 : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public Form面料日记账()
        {
            InitializeComponent();
        }

        private void dateTimePicker1_ValueChanged_1(object sender, EventArgs e)
        {
            string date = this.dateTimePicker1.Value.ToString();
            //webservice取值
            //this.gridControl日记账.DataSource = 面料记录Service.get面料日记账(date);
        }

        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            SaveFileDialog fileDialog = new SaveFileDialog();
            fileDialog.Title = "导出Excel";
            fileDialog.Filter = "Excel文件(*.xls)|*.xls";
            DialogResult dialogResult = fileDialog.ShowDialog(this);
            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                this.gridControl日记账.ExportToXls(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void gridView日记账_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            String orderId = FunctionHelper.GetgridViewValue(
                this.gridView日记账,
                this.gridView日记账.FocusedRowHandle,
                "orderId"
                );
            if (!String.IsNullOrEmpty(orderId))
            {
                this.gridControl异常调整.DataSource = 面料记录Service.get异常调整(orderId);
            }
            else
            {
                this.gridControl异常调整.DataSource = null;
                this.gridView异常调整.RefreshData();
                return;
            }
            
        }
    }
    
}